import pickle
from DataSet.Tools_TSNscore import load_TSNscore

filepath = '/mnt/md0/Qiu/Code/TCN3/actNet200-V1-3.pkl'

with open(filepath,'rb') as f:
    d = pickle.load(f)

d.keys()
# dict_keys(['taxonomy', 'version', 'actionIDs', 'database'])

database = d['database']
keys = list(database.keys())
database[keys[10]]

'''
增加了:
       class
       sf,ef
       fps
       numf

Out[8]: 
{'annotations': [{'class': 106,
   'ef': 2488,
   'label': 'Shoveling snow',
   'nodeid': 183,
   'segment': [0.01, 83.05780045351474],
   'sf': 0}],
 'duration': 83.06,
 'fps': 29.97002997002997,
 'isnull': 0,
 'newResolution': [256, 342],
 'numf': 2488,
 'resolution': '640x480',
 'subset': 'training',
 'url': 'https://www.youtube.com/watch?v=hHiPEAiYKv0'}
 
'''

# 检查特征长度和frame长度是否是对应的

eq = 0
neq = 0
cnt = 0

for key in keys:
    D = database[key]
    if D['subset'] == 'testing':
        continue
    numf = D['numf']
    try:
        feat = load_TSNscore(key)
    except Exception as E:
        continue

    cnt += 1
    featnum = feat.shape[0]

    ffn = featnum/0.4

    w = input()
    print(featnum,numf,ffn)

    if featnum != numf :
        neq+=1
    else :
        eq+=1

    if cnt%20 == 0:
        print('eq ',eq,' neq ',neq)
